<!-- 我的弹窗 -->

<template>
  <WebModal small>
    <WebForm>
      <FormSelect label="系统类型" bind="configType" :dict="DICT.TYPE" half required />

      <FormFile
        label="模型文件"
        bind="modelUrlList"
        folder="model"
        :upload="upload"
        :limit="1"
        required
        @change="changeModelUrl"
      />

      <FormFile
        label="源文件"
        bind="originUrlList"
        folder="model"
        :upload="upload"
        :limit="1"
        @change="changeOriginUrl"
      />

      <FormPhoto label="预览图" bind="previewUrl" folder="model" :upload="upload" :pathTrans="pathTrans" square />

      <FormTextarea label="备注" bind="remark" :max="100" />
    </WebForm>
  </WebModal>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyModal',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 上传方法
     */
    upload(file, folder) {
      return CORE._3DFileUpload(file, folder)
    },

    /**
     * 路径转换
     */
    pathTrans(path) {
      return CORE._3Dfile(path)
    },

    /**
     * 切换模型文件
     */
    changeModelUrl(urlList) {
      this.one.modelUrl = CORE.isEmpty(urlList) ? '' : urlList[0].fileUrl
    },

    /**
     * 切换源文件
     */
    changeOriginUrl(urlList) {
      this.one.originUrl = CORE.isEmpty(urlList) ? '' : urlList[0].fileUrl
    },
  },
}
</script>
